home *** CD-ROM | disk | FTP | other *** search
- /*
- ** Author: Markus van Kempen
- ** Date : 17. Dezember 1992
- **
- ** This demo shows you how to make gadgets
- **
- ** with the EGS STACK LANGUAGE. But remember:
- **
- ** normally you do not need the STACK-LANGUAGE, because you can
- **
- ** do the same stuff much easier with the egsgadbox.library
- **
- ** (refer to demo gadget).
- **
- **
- **
- ** In these files you will find some useful routines
- ** for opening and closing Libraries and error handling
- **
- ** (c) by VIONA-Development
- **
- */
-
- #include "includes.c"
- #include "Global.h"
- #include "stack-language.c"
- #include "Eventloop.c"
- #include "InitMenu.c"
-
- BOOL InitLibraries(struct OpenStructTyp *);
- void CloseLibraries(struct OpenStructTyp *);
-
-
- /*
- ** Opens the libs from the OpenStructTyp
- ** (see global.h)
- **
- */
-
- BOOL InitLibraries(struct OpenStructTyp *OS)
- {
- struct OpenStructTyp *p = &OS[0];
-
- while (p->Ort != NULL)
- {
- if ((*(p->Ort) = (ULONG)OpenLibrary(p->Name,p->Version)) == NULL)
- {
- printf(" Can't open %s version %d",p->Name, p->Version);
- return FALSE;
- }
- else
- { p ++; }
- }
- return TRUE;
- }
-
-
- /*
- ** Close the Libs from the OpenStructTyp
- **
- */
- void CloseLibraries(struct OpenStructTyp *OS)
- {
- struct OpenStructTyp *p = &OS[0];
-
- while (*(p->Ort) != NULL && p->Name != NULL)
- {
- CloseLibrary((void *)(*(p->Ort)));
- *(p->Ort) = NULL;
- p++;
- }
- }
- /**/
-
-
- /*
- ** This routine is for error handling.
- ** It closes all open things of the
- ** program.
- **
- */
- void myError(char *string)
- {
- if ( string != NULL)
- {
- if ( EGSRequestBase == NULL )
- {
- printf("%s\n",string);
-
- }else{
-
- ErrorReq = (ER_SimpleRequestPtr)ER_CreateSimpleRequest(NULL,
- (char *)string,(char *)"OK");
-
-
-
- /*
- ** Open requester in the middle of the screen,
- **
- ** if you can!
- */
-
- ErrorReq->Req.Nw->Flags |= EI_WINDOWCENTER;
-
- ER_DoRequest(&(ErrorReq->Req)) ;
- }
- }
-
- if (Window)
- {
-
- ErrorReq = ER_CreateSimpleRequest(NULL,
- "Hello world !|This is a Requester !","OK");
-
- ErrorReq->Req.Nw->Flags |= EI_WINDOWCENTER;
-
- ER_DoRequest(&(ErrorReq->Req)) ;
- }
-
- if ( FontforMenu )
- EG_CloseFont(FontforMenu);
-
- if ( Window )
- EI_CloseWindow(Window);
-
- if ( Menu )
- EI_FreeMenu(Menu);
-
- if ( ErrorReq )
- ER_DeleteRequest(&(ErrorReq->Req));
-
- CloseLibraries(OpenStruct);
-
- exit(0);
-
-
- }
- /**/
-
- int main(int argc, char *argv[])
- {
-
- if (argc == 2 && strcmp("?",argv[1]) == 0)
- {
- printf("Aufruf: %s\n Markus van Kempen 12 Nov 1992",argv[0]);
-
- }else
- {
-
- if ( InitLibraries(OpenStruct) == FALSE)
- myError("Can't OpenLibrary");
-
- FontforMenu = (EG_EFontPtr)EG_OpenFont((struct TextAttr *)&FontStr);
-
- if ( FontforMenu == NULL )
- myError("Could not open font");
-
- Menu=InitMenu(FontforMenu);
-
- if ( Menu == NULL )
- myError("Could not build menu");
-
- newwin.FirstGadgets=(struct EI_Gadget *)&myBoolGadget;
- newwin.Menu=Menu;
- newwin.Title=argv[0];
-
- Window = (EI_WindowPtr)EI_OpenWindow ((struct EI_NewWindow *)&newwin);
-
- if (Window)
- {
-
- HandleEvents(Window);
-
- }else{
- myError("Could not open window");
- }
- }
- myError(NULL);
- }
-
-
-
-